package com.home.jinlanhua.utils;

import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException;
import org.json.JSONException;

import java.io.IOException;

/**
 * Created by lzr on 2019-08-26.
 */
public class MessageUtil {
//    public static void main (String[] args) {
//        System.out.println(sendMessage("000000", "15858805029"));
//    }

    public static String sendMessage(String serial, String phone) {
        try {
            String[] params = {serial};
            SmsSingleSender sender = new SmsSingleSender(Const.APP_ID, Const.APP_KEY);
            SmsSingleSenderResult result = sender.sendWithParam(Const.NATION_CODE, phone,
                    Const.TEMPLETEID, params, Const.SMS_SIGN, "", "");
            return result.toString();
        } catch (
                HTTPException | JSONException | IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
